install.packages("packcircles")
library(packcircles)
install.packages("ggplot2")
library(ggplot2)
install.packages("virdis")
library(viridis)
install.packages("virdis")
install.packages("viridis")
library(viridis)
library(viridis)
# Create data
data=data.frame(group=paste("Group", letters[1:20]), value=sample(seq(1,100),20))
# Generate the layout. sizetype can be area or radius, following your preference on what to be proportional to value.
packing <- circleProgressiveLayout(data$value, sizetype='area')
data = cbind(data, packing)
dat.gg <- circleLayoutVertices(packing, npoints=50)
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
# 2 -- Custom the color of the dots: proportional to the value:
# First I need to add the 'value' of each group to dat.gg.
# Here I repeat each value 51 times since I create my polygons with 50 lines
dat.gg$value=rep(data$value, each=51)
ggplot() +
# Make the bubbles
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=value), colour = "black", alpha = 0.6) +
scale_fill_distiller(palette = "BuPu", direction = 1 ) +
# Add text in the center of each bubble + control its size
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
# General theme:
theme_void()  +
theme(legend.position="none") +
coord_equal()
# 3 -- Let's try with a black background and more obvious labels:
ggplot() +
# Make the bubbles
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=value), colour = "grey", alpha = 0.6, size=.5) +
scale_fill_distiller(palette = "Spectral", direction = 1 ) +
# Add text in the center of each bubble + control its size
geom_label(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
# General theme:
theme_void()  +
theme(
legend.position="none",
plot.background = element_rect(fill="black"),
plot.title = element_text(color="white", margin = margin(t = 20))
) +
coord_equal() +
ggtitle("A custom circle packing with\nblack background")
# 3 -- Let's try with a black background and more obvious labels:
ggplot() +
# Make the bubbles
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=value), colour = "grey", alpha = 0.6, size=.5) +
scale_fill_distiller(palette = "Spectral", direction = 1 ) +
# Add text in the center of each bubble + control its size
geom_label(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
# General theme:
theme_void()  +
theme(
legend.position="none",
plot.background = element_rect(fill="black"),
plot.title = element_text(color="white", margin = margin(t = 20))
) +
coord_equal() +
ggtitle("A custom circle packing with\nblack background")
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
# 2 -- Custom the color of the dots: proportional to the value:
# First I need to add the 'value' of each group to dat.gg.
# Here I repeat each value 51 times since I create my polygons with 50 lines
dat.gg$value=rep(data$value, each=51)
ggplot() +
# Make the bubbles
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=value), colour = "black", alpha = 0.6) +
scale_fill_distiller(palette = "BuPu", direction = 1 ) +
# Add text in the center of each bubble + control its size
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
# General theme:
theme_void()  +
theme(legend.position="none") +
coord_equal()
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
install.packages("readxl")
library(readxl)
google <- read_excel("googleplaystore1.xlsx")
google2$Size <- ifelse(google1$Size == 'Varies with device', NA , google1$Size)
google$Size <- ifelse(google$Size == 'Varies with device', NA , google$Size)
google <- na.omit(google)
install.packages("dplyr")
install.packages("dplyr")
install.packages("dplyr")
install.packages("dplyr")
library(dplyr)
google$Rating <- ifelse(google$Rating == 'NaN', NA , google$Rating)
google <- na.omit(google)
google_category <- google %>% group_by(Category)
install.packages("dplyr")
install.packages("dplyr")
library(dplyr)
google_category <- google %>% group_by(Category)
google$Installs <- ifelse( google$Installs == '1+', 1,
ifelse(google$Installs == '10+', 10 ,
ifelse(google$Installs == '100+',100,
ifelse(google$Installs == '1,000+',1000,
ifelse(google$Installs == '10,000+',10000,
ifelse(google$Installs=='100,000+',100000,
ifelse(google$Installs=='5+',5,
ifelse(google$Installs=='50+',50,
ifelse(google$Installs=='500+',500,
ifelse(google$Installs =='5,000+',5000,
ifelse(google$Installs=='50,000+',50000,
ifelse(google$Installs=='1,000,000+',1000000,
ifelse(google$Installs=='500,000+',500000,
ifelse(google$Installs=='5,000,000+',5000000,
ifelse(google$Installs=='10,000,000+',10000000,
ifelse(google$Installs=='50,000,000+',50000000,
ifelse(google$Installs=='100,000,000+',100000000,
ifelse(google$Installs=='500,000,000+',500000000,
ifelse(google$Installs=='1,000,000,000+',1000000000,NA)))))))))))))))))))
google$Reviews <- as.numeric(google$Reviews)
Category_install <- google %>%
filter(!is.na(Installs) & !is.na(Category) & !is.na(Type)) %>%
group_by(Category) %>%
summarise(mean_install = mean(Installs)) %>%
arrange(desc(mean_install))
# Create data
data <- data.frame(group=google_category, value=Category_install$mean_install)
# Create data
data <- data.frame(group=Category_install$Category, value=Category_install$mean_install)
# Generate the layout. sizetype can be area or radius, following your preference on what to be proportional to value.
packing <- circleProgressiveLayout(data$value, sizetype='area')
library(packcircles)
library(ggplot2)
library(viridis)
# Generate the layout. sizetype can be area or radius, following your preference on what to be proportional to value.
packing <- circleProgressiveLayout(data$value, sizetype='area')
data = cbind(data, packing)
dat.gg <- circleLayoutVertices(packing, npoints=50)
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
View(Category_install)
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.8) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.4) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
category <- google %>%
filter(!is.na(Category)) %>%
group_by(Category) %>%
summarise(sum = sum(Category)) %>%
arrange(desc(sum))
category <- google %>%
filter(!is.na(Category)) %>%
group_by(Category) %>%
summarise(n = n(Category)) %>%
arrange(desc(sum))
category <- google %>%
filter(!is.na(Category)) %>%
group_by(Category) %>%
summarise(n = n(Category)) %>%
arrange(desc(n))
category <- google %>%
filter(!is.na(Category)) %>%
group_by(Category) %>%
summarise(n = n()) %>%
arrange(desc(n))
View(category)
# Create data
data <- data.frame(group=category$Category, value=category$n)
# Generate the layout. sizetype can be area or radius, following your preference on what to be proportional to value.
packing <- circleProgressiveLayout(data$value, sizetype='area')
data = cbind(data, packing)
dat.gg <- circleLayoutVertices(packing, npoints=50)
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
#####################
# 장르별 다운로드 수와 사이즈 비교
summarise(google$Size)
#####################
# 장르별 다운로드 수와 사이즈 비교
summary(google$Size)
###########
#장르별 다운로드수와 리뷰 수 비교
install.packages("tidyverse")
library(tidyverse)
# Create data
value1=abs(rnorm(26))*2
data=data.frame(x=LETTERS[1:26], value1=value1, value2=value1+1+rnorm(26, sd=1) )
# Reorder data using average?
data = data %>% rowwise() %>% mutate( mymean = mean(c(value1,value2) )) %>% arrange(mymean) %>% mutate(x=factor(x, x))
# plot
ggplot(data) +
geom_segment( aes(x=x, xend=x, y=value1, yend=value2), color="grey") +
geom_point( aes(x=x, y=value1), color=rgb(0.2,0.7,0.1,0.5), size=3 ) +
geom_point( aes(x=x, y=value2), color=rgb(0.7,0.2,0.1,0.5), size=3 ) +
coord_flip()
# With a bit more style
ggplot(data) +
geom_segment( aes(x=x, xend=x, y=value1, yend=value2), color="grey") +
geom_point( aes(x=x, y=value1), color=rgb(0.2,0.7,0.1,0.5), size=3 ) +
geom_point( aes(x=x, y=value2), color=rgb(0.7,0.2,0.1,0.5), size=3 ) +
coord_flip()+
theme_light() +
theme(
legend.position = "none",
panel.border = element_blank(),
) +
xlab("") +
ylab("Value of Y")
Category_review <- google %>%
filter(!is.na(Category) & !is.na(Reviews)) %>%
group_by(Category) %>%
summarise(mean_review = mean(Reviews)) %>%
arrange(desc(mean_review))
# Create data
value1 <- Category_install$mean_install
data=data.frame(x=Category_install$Category, value1=value1, value2=Category_review$mean_review )
# Reorder data using average?
data = data %>% rowwise() %>% mutate( mymean = c(value1,value2) ) %>% arrange(mymean) %>% mutate(x=factor(x, x))
data <- data.frame(x=Category_install$Category, value1=value1, value2=Category_review$mean_review )
# Reorder data using average?
data = data %>% rowwise() %>% mutate( mymean = c(value1,value2) ) %>% arrange(mymean) %>% mutate(x=factor(x, x))
View(Category_review)
summary(Category_install$mean_install)
summary(Category_review$mean_review)
data <- data.frame(x=Category_install$Category, value1=value1/100, value2=Category_review$mean_review )
# Reorder data using average?
data = data %>% rowwise() %>% mutate( mymean = c(value1,value2) ) %>% arrange(mymean) %>% mutate(x=factor(x, x))
data <- data.frame(x=Category_install$Category, value1=value1/1000, value2=Category_review$mean_review )
# Reorder data using average?
data = data %>% rowwise() %>% mutate( mymean = c(value1,value2) ) %>% arrange(mymean) %>% mutate(x=factor(x, x))
data <- data.frame(x=Category_install$Category, value1=Category_install$mean_install/1000, value2=Category_review$mean_review )
# Reorder data using average?
data <- data %>% rowwise() %>% mutate( mymean = c(value1, value2) ) %>% arrange(mymean) %>% mutate(x=factor(x, x))
# Reorder data using average?
data <- data %>% rowwise() %>% mutate( mymean = mean(c(value1, value2)) ) %>% arrange(mymean) %>% mutate(x=factor(x, x))
# plot
ggplot(data) +
geom_segment( aes(x=x, xend=x, y=value1, yend=value2), color="grey") +
geom_point( aes(x=x, y=value1), color=rgb(0.2,0.7,0.1,0.5), size=3 ) +
geom_point( aes(x=x, y=value2), color=rgb(0.7,0.2,0.1,0.5), size=3 ) +
coord_flip()
data <- data.frame(x=Category_install$Category, value1=Category_install$mean_install, value2=Category_review$mean_review )
# Reorder data using average?
data <- data %>% rowwise() %>% mutate( mymean = mean(c(value1, value2)) ) %>% arrange(mymean) %>% mutate(x=factor(x, x))
# plot
ggplot(data) +
geom_segment( aes(x=x, xend=x, y=value1, yend=value2), color="grey") +
geom_point( aes(x=x, y=value1), color=rgb(0.2,0.7,0.1,0.5), size=3 ) +
geom_point( aes(x=x, y=value2), color=rgb(0.7,0.2,0.1,0.5), size=3 ) +
coord_flip()
# default barplot
ggplot(mtcars, aes(x=as.factor(cyl), fill=as.factor(cyl) )) +
geom_bar( )
# 1/ scale_colour_hue(), It picks evenly spaced hues around the hcl colour wheel.
ggplot(mtcars, aes(x=as.factor(cyl), fill=as.factor(cyl) )) +
geom_bar( ) +
scale_fill_hue(h = c(180, 300))
# default barplot
ggplot(mtcars, aes(x=as.factor(cyl), fill=as.factor(cyl) )) +
geom_bar( )
# default barplot
ggplot(data=Category_install, aes(x=as.factor(Category_install$Category), y=Category_install$mean_install , fill=as.factor(Category_install$Category) )) +
geom_bar( ) + coord_flip()
# default barplo
ggplot(data=Category_install, aes( x = reorder(Category_install$Category,-Category_install$mean_install), y=Category_install$mean_install , fill=Category_install$Category )) +
geom_bar( ) + coord_flip()
# 1/ scale_colour_hue(), It picks evenly spaced hues around the hcl colour wheel.
ggplot(mtcars, aes(x=as.factor(cyl), fill=as.factor(cyl) )) +
geom_bar( ) +
scale_fill_hue(h = c(180, 300))
# default barplo
ggplot(data=Category_install, aes( x = reorder(Category_install$Category,-Category_install$mean_install), y=Category_install$mean_install , fill=Category_install$Category )) +
scale_fill_hue(h = c(180, 300)) +
geom_bar( ) + coord_flip()
# default barplo
ggplot(data=Category_install, aes( x = reorder(Category_install$Category,-Category_install$mean_install), y=Category_install$mean_install )) +
scale_fill_hue(h = c(180, 300)) +
geom_bar( ) + coord_flip()
# default barplo
ggplot(data=Category_install, aes( x = reorder(Category_install$Category,-Category_install$mean_install), fill=Category_install$mean_install )) +
scale_fill_hue(h = c(180, 300)) +
geom_bar( ) + coord_flip()
# default barplo
ggplot(data=Category_install, aes( x = reorder(Category_install$Category,-Category_install$mean_install), fill=Category_install$mean_install )) +
geom_bar( ) + coord_flip()
# default barplo
ggplot(data=Category_install, aes( x = reorder(Category_install$Category,Category_install$mean_install), fill=Category_install$mean_install )) +
geom_bar( ) + coord_flip()
ggplot(data=Category_review, aes( x = reorder(Category_review$Category,Category_review$mean_review), fill=Category_review$mean_review )) +
geom_bar( ) + coord_flip()
# default barplo
result <- ggplot(data=Category_install, aes( x = reorder(Category_install$Category,Category_install$mean_install), fill=Category_install$mean_install )) +
geom_bar( ) + coord_flip()
result2 <- ggplot(data=Category_review, aes( x = reorder(Category_review$Category,Category_review$mean_review), fill=Category_review$mean_review )) +
geom_bar( ) + coord_flip()
# default barplo
result1 <- ggplot(data=Category_install, aes( x = reorder(Category_install$Category,Category_install$mean_install), fill=Category_install$mean_install )) +
geom_bar( ) + coord_flip()
result1 + labs(x="Genre",y="Installs Count",title = "Installs by genre")
result2 + labs(x="Genre",y="Review Count",title = "Reviews by genre")
result1 + labs(x="Genre",y="Installs Count",title = "Installs by genre")
result2 + labs(x="Genre",y="Review Count",title = "Reviews by genre")
google$Size <- gsub("M")
google1 <- google
google1$Size <- gsub("M",google1$Size)
View(google)
google1$Size <- gsub('M' ,google1$Size)
x = google1$Size
google1$Size <- gsub('M' ,x)
google1$Size <- gsub('M',"" ,google1$Size)
View(google)
View(google1)
google1$Size <- as.numeric(google1$Size)
is.numeric(google1$Size)
Category_install_size <- google1 %>%
filter(!is.na(google1$Size) & !is.na(google1$Category) & !is.na(google1$Installs)) %>%
group_by(google1$Category) %>%
summarise(mean_install = mean(google1$Installs)) %>%
summarise(mean_size = mean(google1$Size)) %>%
arrange(desc(mean_size))
Category_install_size <- google1 %>%
filter(!is.na(Size) & !is.na(Category) & !is.na(Installs)) %>%
group_by(Category) %>%
summarise(mean_install = mean(Installs)) %>%
summarise(mean_size = mean(Size)) %>%
arrange(desc(mean_size))
Category_install_size <- google1 %>%
filter(!is.na(Size) & !is.na(Category) & !is.na(Installs)) %>%
group_by(Category) %>%
summarise(mean_install = mean(Installs)) %>%
summarise(mean_size = mean(Size)) %>%
arrange(desc(mean_size))
Category_install_size <- google1 %>%
filter(!is.na(Size) & !is.na(Category) & !is.na(Installs)) %>%
group_by(Category) %>%
summarise(mean_install = mean(Installs) , mean_size = mean(Size)) %>%
arrange(desc(mean_size))
View(Category_install_size)
result3 <- ggplot(data=Category_install_size, aes( x = reorder(Category_install_size$Category,Category_install_size$mean_install) , y= Category_install_size$mean_size)) +
geom_col( ) + coord_flip()
result3 + labs(x="Genre",y="Size And Install",title = "Size by genre")
result3 <- ggplot(data=Category_install_size, aes( x = reorder(Category_install_size$Category,Category_install_size$mean_install) , y= Category_install_size$mean_size)) +
geom_col( ) + coord_flip()
View(Category_install_size)
# default barplo
result1 <- ggplot(data=Category_install, aes( x = reorder(Category_install$Category,Category_install$mean_install), fill=Category_install$mean_install )) +
geom_bar( ) + coord_flip()
result1 + labs(x="Genre",y="Installs Count",title = "Installs by genre")
result3 + labs(x="Genre",y="Size And Install",title = "Size by genre")
# Create data
data <- data.frame(group=category$Category, value=category$n)
# Generate the layout. sizetype can be area or radius, following your preference on what to be proportional to value.
packing <- circleProgressiveLayout(data$value, sizetype='area')
data = cbind(data, packing)
dat.gg <- circleLayoutVertices(packing, npoints=50)
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
View(Category_install)
# Create data
data <- data.frame(group=category$Category, value=category$n)
# Generate the layout. sizetype can be area or radius, following your preference on what to be proportional to value.
packing <- circleProgressiveLayout(data$value, sizetype='area')
data <- cbind(data, packing)
dat.gg <- circleLayoutVertices(packing, npoints=50)
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
# default barplo
result1 <- ggplot(data=Category_install, aes( x = reorder(Category_install$Category,Category_install$mean_install), fill=Category_install$mean_install )) +
geom_bar( ) + coord_flip()
result1 + labs(x="Genre",y="Installs Count",title = "Installs by genre")
# 1 -- Custom the color: whatever palette. (see ggplot2 section for more explanation)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
View(google)
google5<-read_excel("googleplaystore1.xlsx")
install.packages("readxl")
library(readxl)
google5<-read_excel("googleplaystore1.xlsx")
View(google5)
